# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=lua-feedparser
_rockname=feedparser
pkgver=0.71
pkgrel=3
pkgdesc="decent RSS and Atom XML feed parser"
url="https://github.com/slact/lua-feedparser"
arch="noarch"
license="BSD-3-Clause"
depends="lua lua-expat"
source="$pkgname-$pkgver.tar.gz::https://github.com/slact/lua-feedparser/archive/$pkgver.tar.gz"

provides="$pkgname-common=$pkgver-r$pkgrel"  # for backward compatibility
replaces="$pkgname-common"  # for backward compatibility

_luaversions="5.1 5.2 5.3 5.4"
for _v in $_luaversions; do
	checkdepends="$checkdepends lua$_v"
	provides="$provides lua$_v-${pkgname#lua-}=$pkgver-r$pkgrel"  # for backward compatibility
done

check() {
	local lver; for lver in $_luaversions; do
		msg "Testing on Lua $lver"
		make test LUA_BIN=lua$lver
	done
}

package() {
	local lmod_dir="$pkgdir/usr/share/lua/common"
	local rockdir="$pkgdir/usr/lib/luarocks/rocks-common/$_rockname/$pkgver-3"

	mkdir -p "$lmod_dir"
	make LUA_DIR="$lmod_dir" install

	mkdir -p "$rockdir"
	echo 'rock_manifest = {}' > "$rockdir"/rock_manifest
}

sha512sums="
8a65947b5472321fc162ec325c31e4d92e52e6cba6952c01c9941a7596403ed495ee464bfc32f5fdda3c58d33fae3a3b38882f7f22ecc16360c6603cd7ab4d4d  lua-feedparser-0.71.tar.gz
"
